﻿namespace LiteBlog.Controllers.Extensions
{
    using System.Web.Mvc;
    using System.Web.Mvc.Html;
    using System.Linq;
    using System.Collections.Generic;

    public static class ModelStateExtension
    {
        public static List<string> Errors(this ModelStateDictionary modelStateDic)
        {
            var errors = new List<string>();
            foreach (var modelState in modelStateDic.Values)
                foreach (var error in modelState.Errors)
                {
                    errors.Add(error.ErrorMessage);
                }

            return errors;
        }
    }
}